package com.apple1.commonutil.common;

import java.util.Properties;

/**
 *	服务器返回通用类
 * @author huangliwei
 * @date   2019年1月20日
 */
public class ServerResponse {
	
	/**
	 * 失败的调用
	 * @param properties
	 * @param info
	 * @return
	 */
	public static Properties failBack(Properties properties, Object info) {
		properties.put("code", 500);
		properties.put("result", "fail");
		properties.put("info", info);
		return properties;
	}
	
	public static Properties successBack(Properties properties, Object info) {
		properties.put("code", 200);
		properties.put("result", "success");
		properties.put("info", info);
		return properties;
	}
	
	public static Properties successBack(Properties properties) {
		properties.put("code", 200);
		properties.put("result", "success");
		return properties;
	}
	
	/**
	 * 判断返回是否成功
	 * @param properties
	 * @return
	 */
	public static boolean isSuccess(Properties properties) {
		if(properties != null && "success".equals(properties.get("result"))) {
			return true;
		}
		return false;
	}

}
